package javbot.gui.actions;

import java.util.Iterator;

import javax.swing.JDialog;

import javbot.gui.JavbotFrame;
import javbot.gui.KeyPanel;

public class CmdKeyAction extends BaseAction {

	private static final long serialVersionUID = -7987177856040768755L;

	/**
	 * @param frame
	 */
	public CmdKeyAction(JavbotFrame frame) {
		super(frame);
	}

	public void actionPerformed(java.awt.event.ActionEvent e) {
		JDialog d = new JDialog(frame, "Key", true);
		KeyPanel kp = new KeyPanel();
		d.setSize(kp.getPreferredSize());
		d.setContentPane(kp);
		d.setVisible(true);
		
		if (kp.buttons.size() > 0) {
			Iterator<String> t = kp.buttons.iterator();
			String s = "Key ";
	
			while (t.hasNext()) {
				s += t.next();
				if (t.hasNext()) {
					s += ", ";
				}
			}
			frame.javbotPanel.scriptPanel.insertKey(s);
		}
			
		
		
	}
}